<script>
	import {handleLogin,SetBaseStatus} from './utils/request';
	
	//#ifdef APP-PLUS
	const ToolKit = uni.requireNativePlugin('toolkit');
	//#endif
	export default {
		globalData: {  
		  timerFun: null    //用来定义轮训
		},
		methods:{
			getDeviceId() {
				//#ifdef APP-PLUS 
				ToolKit.getDeviceID((resCode)=>{
					this.$store.commit('updateDevice',resCode);
					 SetBaseStatus(resCode).then(()=>{
						 uni.$u.toast('开始登录')
						 handleLogin(resCode);
					 });
				})
				//#endif
			},	
		},
		onLaunch: function() {
			//#ifdef APP-PLUS 
			ToolKit.setCompleteConnectionListener((res)=>{
				this.getDeviceId(); 
			});
			//#endif
			
			console.log('App Launch')
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	@import "uview-ui/index.scss";
	
</style>
